/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-07-30
 * Time: 19:43
 */

class Solution {
    public boolean isUgly(int n) {
        if (n <= 0) return false;
        while (n % 2 == 0) n /= 2;
        while (n % 3 == 0) n /= 3;
        while (n % 5 == 0) n /= 5;
        return n == 1;
    }
}
public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.isUgly(16));
    }
}
